home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / UnicodeConverter.a < prev    next >
Encoding:
Text File  |  1998-02-12  |  12.4 KB  |  338 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        UnicodeConverter.a
  3. ;
  4. ;    Contains:    Types, constants, and prototypes for Unicode Converter
  5. ;
  6. ;    Version:    Technology:    Mac OS 8
  7. ;                Release:    Universal Interfaces 3.1
  8. ;
  9. ;    Copyright:    © 1994-1998 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__UNICODECONVERTER__') = 'UNDEFINED' THEN
  19. __UNICODECONVERTER__ SET 1
  20.  
  21.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  22.     include 'MacTypes.a'
  23.     ENDIF
  24.     IF &TYPE('__TEXTCOMMON__') = 'UNDEFINED' THEN
  25.     include 'TextCommon.a'
  26.     ENDIF
  27.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  28.     include 'MixedMode.a'
  29.     ENDIF
  30.  
  31. ;  Unicode conversion contexts: 
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. ;  UnicodeMapVersion type & values 
  39. ; typedef SInt32                         UnicodeMapVersion
  40.  
  41.  
  42. kUnicodeUseLatestMapping        EQU        -1
  43. kUnicodeUseHFSPlusMapping        EQU        4
  44. ;  Types used in conversion 
  45. UnicodeMapping            RECORD 0
  46. unicodeEncoding             ds.l    1                ; offset: $0 (0)
  47. otherEncoding             ds.l    1                ; offset: $4 (4)
  48. mappingVersion             ds.l    1                ; offset: $8 (8)
  49. sizeof                     EQU *                    ; size:   $C (12)
  50.                         ENDR
  51. ; typedef struct UnicodeMapping *        UnicodeMappingPtr
  52.  
  53. ; typedef const struct UnicodeMapping *    ConstUnicodeMappingPtr
  54.  
  55. ;  Control flags for ConvertFromUnicodeToText and ConvertFromTextToUnicode 
  56.  
  57. kUnicodeUseFallbacksBit            EQU        0
  58. kUnicodeKeepInfoBit                EQU        1
  59. kUnicodeDirectionalityBits        EQU        2
  60. kUnicodeVerticalFormBit            EQU        4
  61. kUnicodeLooseMappingsBit        EQU        5
  62. kUnicodeStringUnterminatedBit    EQU        6
  63. kUnicodeTextRunBit                EQU        7
  64. kUnicodeKeepSameEncodingBit        EQU        8
  65.  
  66. kUnicodeUseFallbacksMask        EQU        $00000001
  67. kUnicodeKeepInfoMask            EQU        $00000002
  68. kUnicodeDirectionalityMask        EQU        $0000000C
  69. kUnicodeVerticalFormMask        EQU        $00000010
  70. kUnicodeLooseMappingsMask        EQU        $00000020
  71. kUnicodeStringUnterminatedMask    EQU        $00000040
  72. kUnicodeTextRunMask                EQU        $00000080
  73. kUnicodeKeepSameEncodingMask    EQU        $00000100
  74. ;  Values for kUnicodeDirectionality field 
  75.  
  76. kUnicodeDefaultDirection        EQU        0
  77. kUnicodeLeftToRight                EQU        1
  78. kUnicodeRightToLeft                EQU        2
  79. ;  Directionality masks for control flags 
  80.  
  81. kUnicodeDefaultDirectionMask    EQU        $00
  82. kUnicodeLeftToRightMask            EQU        $04
  83. kUnicodeRightToLeftMask            EQU        $08
  84. ;  Control flags for TruncateForUnicodeToText: 
  85.  
  86. ;   Now TruncateForUnicodeToText uses control flags from the same set as used by
  87. ;   ConvertFromTextToUnicode, ConvertFromUnicodeToText, etc., but only
  88. ;   kUnicodeStringUnterminatedMask is meaningful for TruncateForUnicodeToText.
  89. ;   
  90. ;   Previously two special control flags were defined for TruncateForUnicodeToText:
  91. ;          kUnicodeTextElementSafeBit = 0
  92. ;          kUnicodeRestartSafeBit = 1
  93. ;   However, neither of these was implemented.
  94. ;   Instead of implementing kUnicodeTextElementSafeBit, we now use
  95. ;   kUnicodeStringUnterminatedMask since it accomplishes the same thing and avoids
  96. ;   having special flags just for TruncateForUnicodeToText
  97. ;   Also, kUnicodeRestartSafeBit is unnecessary, since restart-safeness is handled by
  98. ;   setting kUnicodeKeepInfoBit with ConvertFromUnicodeToText.
  99. ;   If TruncateForUnicodeToText is called with one or both of the old special control
  100. ;   flags set (bits 0 or 1), it will not generate a paramErr, but the old bits have no
  101. ;   effect on its operation.
  102.  
  103.  
  104.  
  105. ;  Filter bits for filter field in QueryUnicodeMappings and CountUnicodeMappings: 
  106.  
  107. kUnicodeMatchUnicodeBaseBit        EQU        0
  108. kUnicodeMatchUnicodeVariantBit    EQU        1
  109. kUnicodeMatchUnicodeFormatBit    EQU        2
  110. kUnicodeMatchOtherBaseBit        EQU        3
  111. kUnicodeMatchOtherVariantBit    EQU        4
  112. kUnicodeMatchOtherFormatBit        EQU        5
  113.  
  114. kUnicodeMatchUnicodeBaseMask    EQU        $00000001
  115. kUnicodeMatchUnicodeVariantMask    EQU        $00000002
  116. kUnicodeMatchUnicodeFormatMask    EQU        $00000004
  117. kUnicodeMatchOtherBaseMask        EQU        $00000008
  118. kUnicodeMatchOtherVariantMask    EQU        $00000010
  119. kUnicodeMatchOtherFormatMask    EQU        $00000020
  120. ;  Control flags for SetFallbackUnicodeToText 
  121.  
  122. kUnicodeFallbackSequencingBits    EQU        0
  123.  
  124. kUnicodeFallbackSequencingMask    EQU        $00000003
  125. ;  values for kUnicodeFallbackSequencing field 
  126.  
  127. kUnicodeFallbackDefaultOnly        EQU        0
  128. kUnicodeFallbackCustomOnly        EQU        1
  129. kUnicodeFallbackDefaultFirst    EQU        2
  130. kUnicodeFallbackCustomFirst        EQU        3
  131.  
  132. ;  Caller-supplied entry point to a fallback handler 
  133. ;  Function prototypes 
  134.     IF GENERATING68K ** ¬ GENERATINGCFM THEN
  135.  
  136. ;      Routine to Initialize the Unicode Converter and cleanup once done with it. 
  137. ;      These routines must be called from Static Library clients.
  138.  
  139.  
  140. ;
  141. ; pascal OSStatus InitializeUnicodeConverter(StringPtr TECFileName)
  142. ;
  143.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  144.         IMPORT_CFM_FUNCTION InitializeUnicodeConverter
  145.     ENDIF
  146.  
  147. ;
  148. ; pascal void TerminateUnicodeConverter(void )
  149. ;
  150.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  151.         IMPORT_CFM_FUNCTION TerminateUnicodeConverter
  152.     ENDIF
  153.  
  154. ;  Note: the old names (InitializeUnicode, TerminateUnicode) for the above are still exported.
  155.     ENDIF
  156. ;
  157. ; pascal OSStatus CreateTextToUnicodeInfo(ConstUnicodeMappingPtr iUnicodeMapping, TextToUnicodeInfo *oTextToUnicodeInfo)
  158. ;
  159.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  160.         IMPORT_CFM_FUNCTION CreateTextToUnicodeInfo
  161.     ENDIF
  162.  
  163. ;
  164. ; pascal OSStatus CreateTextToUnicodeInfoByEncoding(TextEncoding iEncoding, TextToUnicodeInfo *oTextToUnicodeInfo)
  165. ;
  166.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  167.         IMPORT_CFM_FUNCTION CreateTextToUnicodeInfoByEncoding
  168.     ENDIF
  169.  
  170. ;
  171. ; pascal OSStatus CreateUnicodeToTextInfo(ConstUnicodeMappingPtr iUnicodeMapping, UnicodeToTextInfo *oUnicodeToTextInfo)
  172. ;
  173.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  174.         IMPORT_CFM_FUNCTION CreateUnicodeToTextInfo
  175.     ENDIF
  176.  
  177. ;
  178. ; pascal OSStatus CreateUnicodeToTextInfoByEncoding(TextEncoding iEncoding, UnicodeToTextInfo *oUnicodeToTextInfo)
  179. ;
  180.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  181.         IMPORT_CFM_FUNCTION CreateUnicodeToTextInfoByEncoding
  182.     ENDIF
  183.  
  184. ;
  185. ; pascal OSStatus CreateUnicodeToTextRunInfo(ItemCount iNumberOfMappings, const UnicodeMapping iUnicodeMappings[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  186. ;
  187.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  188.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfo
  189.     ENDIF
  190.  
  191. ;
  192. ; pascal OSStatus CreateUnicodeToTextRunInfoByEncoding(ItemCount iNumberOfEncodings, const TextEncoding iEncodings[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  193. ;
  194.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  195.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfoByEncoding
  196.     ENDIF
  197.  
  198. ;
  199. ; pascal OSStatus CreateUnicodeToTextRunInfoByScriptCode(ItemCount iNumberOfScriptCodes, const ScriptCode iScripts[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  200. ;
  201.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  202.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfoByScriptCode
  203.     ENDIF
  204.  
  205. ;  Change the TextToUnicodeInfo to another mapping. 
  206. ;
  207. ; pascal OSStatus ChangeTextToUnicodeInfo(TextToUnicodeInfo ioTextToUnicodeInfo, ConstUnicodeMappingPtr iUnicodeMapping)
  208. ;
  209.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  210.         IMPORT_CFM_FUNCTION ChangeTextToUnicodeInfo
  211.     ENDIF
  212.  
  213. ;  Change the UnicodeToTextInfo to another mapping. 
  214. ;
  215. ; pascal OSStatus ChangeUnicodeToTextInfo(UnicodeToTextInfo ioUnicodeToTextInfo, ConstUnicodeMappingPtr iUnicodeMapping)
  216. ;
  217.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  218.         IMPORT_CFM_FUNCTION ChangeUnicodeToTextInfo
  219.     ENDIF
  220.  
  221.  
  222. ;
  223. ; pascal OSStatus DisposeTextToUnicodeInfo(TextToUnicodeInfo *ioTextToUnicodeInfo)
  224. ;
  225.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  226.         IMPORT_CFM_FUNCTION DisposeTextToUnicodeInfo
  227.     ENDIF
  228.  
  229. ;
  230. ; pascal OSStatus DisposeUnicodeToTextInfo(UnicodeToTextInfo *ioUnicodeToTextInfo)
  231. ;
  232.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  233.         IMPORT_CFM_FUNCTION DisposeUnicodeToTextInfo
  234.     ENDIF
  235.  
  236. ;
  237. ; pascal OSStatus DisposeUnicodeToTextRunInfo(UnicodeToTextRunInfo *ioUnicodeToTextRunInfo)
  238. ;
  239.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  240.         IMPORT_CFM_FUNCTION DisposeUnicodeToTextRunInfo
  241.     ENDIF
  242.  
  243. ;
  244. ; pascal OSStatus ConvertFromTextToUnicode(TextToUnicodeInfo iTextToUnicodeInfo, ByteCount iSourceLen, ConstLogicalAddress iSourceStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oSourceRead, ByteCount *oUnicodeLen, UniCharArrayPtr oUnicodeStr)
  245. ;
  246.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  247.         IMPORT_CFM_FUNCTION ConvertFromTextToUnicode
  248.     ENDIF
  249.  
  250. ;
  251. ; pascal OSStatus ConvertFromUnicodeToText(UnicodeToTextInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr)
  252. ;
  253.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  254.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToText
  255.     ENDIF
  256.  
  257. ;
  258. ; pascal OSStatus ConvertFromUnicodeToTextRun(UnicodeToTextRunInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr, ItemCount iEncodingRunBufLen, ItemCount *oEncodingRunOutLen, TextEncodingRun oEncodingRuns[2147483647])
  259. ;
  260.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  261.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToTextRun
  262.     ENDIF
  263.  
  264. ;
  265. ; pascal OSStatus ConvertFromUnicodeToScriptCodeRun(UnicodeToTextRunInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr, ItemCount iScriptRunBufLen, ItemCount *oScriptRunOutLen, ScriptCodeRun oScriptCodeRuns[2147483647])
  266. ;
  267.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  268.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToScriptCodeRun
  269.     ENDIF
  270.  
  271. ;  Truncate a multibyte string at a safe place. 
  272. ;
  273. ; pascal OSStatus TruncateForTextToUnicode(ConstTextToUnicodeInfo iTextToUnicodeInfo, ByteCount iSourceLen, ConstLogicalAddress iSourceStr, ByteCount iMaxLen, ByteCount *oTruncatedLen)
  274. ;
  275.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  276.         IMPORT_CFM_FUNCTION TruncateForTextToUnicode
  277.     ENDIF
  278.  
  279. ;  Truncate a Unicode string at a safe place. 
  280. ;
  281. ; pascal OSStatus TruncateForUnicodeToText(ConstUnicodeToTextInfo iUnicodeToTextInfo, ByteCount iSourceLen, ConstUniCharArrayPtr iSourceStr, OptionBits iControlFlags, ByteCount iMaxLen, ByteCount *oTruncatedLen)
  282. ;
  283.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  284.         IMPORT_CFM_FUNCTION TruncateForUnicodeToText
  285.     ENDIF
  286.  
  287. ;  Convert a Pascal string to Unicode string. 
  288. ;
  289. ; pascal OSStatus ConvertFromPStringToUnicode(TextToUnicodeInfo iTextToUnicodeInfo, ConstStr255Param iPascalStr, ByteCount iOutputBufLen, ByteCount *oUnicodeLen, UniCharArrayPtr oUnicodeStr)
  290. ;
  291.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  292.         IMPORT_CFM_FUNCTION ConvertFromPStringToUnicode
  293.     ENDIF
  294.  
  295. ;  Convert a Unicode string to Pascal string. 
  296. ;
  297. ; pascal OSStatus ConvertFromUnicodeToPString(UnicodeToTextInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, Str255 oPascalStr)
  298. ;
  299.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  300.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToPString
  301.     ENDIF
  302.  
  303. ;  Count the available conversion mappings. 
  304. ;
  305. ; pascal OSStatus CountUnicodeMappings(OptionBits iFilter, ConstUnicodeMappingPtr iFindMapping, ItemCount *oActualCount)
  306. ;
  307.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  308.         IMPORT_CFM_FUNCTION CountUnicodeMappings
  309.     ENDIF
  310.  
  311. ;  Get a list of the available conversion mappings. 
  312. ;
  313. ; pascal OSStatus QueryUnicodeMappings(OptionBits iFilter, ConstUnicodeMappingPtr iFindMapping, ItemCount iMaxCount, ItemCount *oActualCount, UnicodeMapping oReturnedMappings[2147483647])
  314. ;
  315.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  316.         IMPORT_CFM_FUNCTION QueryUnicodeMappings
  317.     ENDIF
  318.  
  319. ;  Setup the fallback handler for converting Unicode To Text. 
  320. ;
  321. ; pascal OSStatus SetFallbackUnicodeToText(UnicodeToTextInfo iUnicodeToTextInfo, UnicodeToTextFallbackUPP iFallback, OptionBits iControlFlags, LogicalAddress iInfoPtr)
  322. ;
  323.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  324.         IMPORT_CFM_FUNCTION SetFallbackUnicodeToText
  325.     ENDIF
  326.  
  327. ;  Setup the fallback handler for converting Unicode To TextRuns. 
  328. ;
  329. ; pascal OSStatus SetFallbackUnicodeToTextRun(UnicodeToTextRunInfo iUnicodeToTextRunInfo, UnicodeToTextFallbackUPP iFallback, OptionBits iControlFlags, LogicalAddress iInfoPtr)
  330. ;
  331.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  332.         IMPORT_CFM_FUNCTION SetFallbackUnicodeToTextRun
  333.     ENDIF
  334.  
  335.  
  336.     ENDIF ; __UNICODECONVERTER__ 
  337.  
  338.